package boot.controller;


import boot.entity.Book;
import boot.service.IBookService;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author HLF
 * @since 2022-04-11
 */
@RestController
@RequestMapping("/book")
public class BookController {
    @Resource
    private IBookService bookService;

    @GetMapping("/insert/{id}")
    public String insert(@PathVariable Integer id) {
        Book book = new Book(id, "SpringCloud", "周阳", new BigDecimal("123.22"));

        MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();

        int i = bookService.insertBook(book);
        if (i > 0)
            return "插入成功！";
        else
            return "插入失败！";
    }
}
